<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"
         import="cn.edu.ecut.se2024.controller.SysController, cn.edu.ecut.se2024.model.UserMenu"%>
<%@ page import="cn.edu.ecut.se2024.model.ShoppingCart" %>
<%@ page import="java.util.List" %>

<%
    List<ShoppingCart> shoppingCarts = (List<ShoppingCart>)request.getSession().getAttribute("showCarts");
    UserMenu userMenu = (UserMenu) request.getSession().getAttribute(SysController.SYS_USER_MENU);
%>

<script type="text/javascript">
    function validate() {
        var x = document.getElementById("searchInput")
        if (x.value == "") {
            alert("请先输入查询内容")
            return false
        }

        return true;
    }
</script>

<body>
<h1>My Carts</h1>
<form action="sys.queryMyCarts" method="post" onsubmit="return validate()">
    <input type="text" name="searchInput" id="searchInput" placeholder="输入查询内容">
    <button type="submit">查询</button>
</form>


<table border="1">
    <tr>
        <th>标题</th>
        <th>价格</th>
        <th>数量</th>
    </tr>
    <%
        for (ShoppingCart cart : shoppingCarts) {
    %>
    <tr>
        <td><%= cart.getTitle() %></td>
        <td><%= cart.getPrice() %></td>
        <td><%= cart.getNum() %></td>
    </tr>
    <% } %>
</table>
</body>
